package com.xxgc.spring.service.impl;

import com.xxgc.spring.dao.UsersMapper;
import com.xxgc.spring.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//service业务逻辑层的实现
//托管业务逻辑层
@Service
@Scope
public class LoginService implements ILoginService {
    //业务逻辑层得和dao层建立通道

    //@Qualifier 结合@Autowired使用，按照id名称进行匹配
    //@Qualifier("usersMapper")
    //相当于@Autowired+@Qualifier

    private UsersMapper um;

    public int userLogin(String name, String pass) {
        System.out.println("登录的业务逻辑被调用");
        System.out.println("去调用Dao层，让Dao层小弟帮我们去数据库找人");
        System.out.println("name="+name);
        System.out.println("pass = " + pass);
        um.selectUsersByUser(name,pass);

        return 0;
    }
    @PostConstruct
    public void init(){
        System.out.println("类创建时调用");
    }

    @PreDestroy
    public void dstroyd(){

        System.out.println("类摧毁时调用");
    }
}
